package com.hospicpc.demos.config;


import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;

public class GetHttpSessionConfig extends ServerEndpointConfig.Configurator {

    /**
     *
     * @param sec
     * @param request
     * @param response
     */
    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        //获取httpSession
        HttpSession httpSession = (HttpSession) request.getHttpSession();
        //保存httpSession对象
        sec.getUserProperties().put(HttpSession.class.getName(),httpSession);
    }
}

